package com.itheima.chapter07.time;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class JDKdemo3 {
    public static void main(String[] args) {
        LocalDateTime localDateTime =LocalDateTime.of(2025,01,02,03,04,05,06);
        System.out.println(localDateTime);//2025-01-02T03:04:05.000000006
        //格式化器
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        //格式化
        String s = localDateTime.format(pattern);
        System.out.println(s);//2025年01月02日 03:04:05
        //解析
        String s1 ="2021年05月07日 15:16:17";
        LocalDateTime parse = localDateTime.parse(s1, pattern);
        System.out.println(parse);//2021-05-07T15:16:17
        System.out.println(parse.getYear());//2021



    }
}
